﻿Imports System.Data.SqlClient
Module cmd
    Public Function con() As SqlConnection
        Dim cn As New SqlConnection("server=.;uid=sa;pwd=123;database=Home_Shoolbd;")
        cn.Open()
        Return cn
    End Function

    Public Sub ExecuteNonQuery(ByVal sql As String)
        Dim cmd As New SqlCommand
        cmd.Connection = con()
        cmd.CommandText = sql
        cmd.ExecuteNonQuery()
    End Sub

    Public Function ExecuteScaler(ByVal sql As String) As Object
        Dim cmd As New SqlCommand
        cmd.Connection = con()
        cmd.CommandText = sql
        Dim value As Object = cmd.ExecuteNonQuery
        Return value
    End Function

    Public Function ExecuteDataTable(ByVal sql As String) As DataTable
        Dim cmd As New SqlCommand
        cmd.Connection = con()
        cmd.CommandText = sql
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader()
        Dim dt As New DataTable
        dt.Load(dr)
        dr.Close()
        Return dt
    End Function
End Module
